<!DOCTYPE HTML>
<html>
<head>
<!--#header start-->
{include file="public/_meta" /}
<!--#header end-->
<title>角色管理</title>
</head>
<body>
<nav class="breadcrumb">
	<i class="Hui-iconfont">&#xe67f;</i> 首页
	<span class="c-gray en">&gt;</span> 管理员管理
	<span class="c-gray en">&gt;</span> 角色管理
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
 </nav>
<div class="page-container">
	<div class="cl pd-5 bg-1 bk-gray">
		 <span class="l">
			  <a href="javascript:;" onclick="datadel()" class="btn btn-danger radius">
					<i class="Hui-iconfont">&#xe6e2;</i>
					批量删除
				</a>
			  <a class="btn btn-primary radius" href="javascript:;" onclick="admin_add('添加角色','{:url('AdminUser/create')}','800')">
				 <i class="Hui-iconfont">&#xe600;</i>
				  添加角色
				</a>
			</span>
			<!-- <span class="r">共有数据：<strong>3</strong> 条</span>  -->
	</div>
	<table class="table table-border table-bordered table-hover table-bg">
    <thead>
			<tr>
				<th scope="col" colspan="11">员工列表</th>
			</tr>
			<tr class="text-c">
				<th width="25"><input type="checkbox" name="" value=""></th>
				<th width="40">ID</th>
				<th width="80">登录名</th>
				<th width="90">手机</th>
				<th width="150">邮箱</th>
				<th width="140">加入时间</th>
				<th width="140">上次登录</th>
				<th width="30">登录次数</th>
				<th width="80">是否已启用</th>
				<th width="200">备注</th>
				<th width="100">操作</th>
			</tr>
		</thead>
		<tbody>
			{volist name="data" id="list"}
				<tr class="text-c">
					<td><input type="checkbox" value="{$list['id']}" name="id[]"></td>
					<td>{$list.id}</td>
					<td>{$list.name}</td>
					<td>{$list.phone}</td>
					<td>{$list.email}</td>
					<td>{$list.register_time | date='Y-m-d H:i:s',###}</td>
					<td>{$list.last_login_time | date='Y-m-d H:i:s',###}</td>
					<td>{$list.login_count}</td>
					<td class="td-status">
						{if condition="$list.status"}
							<span class="label label-success radius">已启用</span>
						{else /}
						  <span class="label label-danger radius">未启用</span>
						{/if}
					</td>
					<td>{$list.remark}</td>
					<td class="td-manage">

						{if condition="$list.id == $userId"}
							<a class="btn btn-warning-outline radius size-MINI" href="javascript:;">
								<i class="Hui-iconfont">&#xe6df;</i>
							</a>
							<a class="btn btn-danger-outline radius size-MINI" href="javascript:;">
								<i class="Hui-iconfont">&#xe6e2;</i>
							</a>
						{else /}
							<a class="btn btn-warning-outline radius size-MINI" title="编辑" href="javascript:;" onclick="admin_edit('角色编辑','{:url('AdminUser/edit')}','{$list.id}')" style="text-decoration:none">
								<i class="Hui-iconfont">&#xe6df;</i>
							</a>
							<a class="btn btn-danger-outline radius size-MINI" title="删除" href="javascript:;" onclick="admin_del(this,'{$list.id}')" style="text-decoration:none">
								<i class="Hui-iconfont">&#xe6e2;</i>
							</a>
						{/if}

					</td>
				</tr>
      {/volist}
		</tbody>
	</table>
</div>

<!--#header start-->
{include file="public/_footer" /}
<!--#header end-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__ADMIN__/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript">
	/*管理员-角色-添加*/
	function admin_add(title,url,w,h){
		layer_show(title,url,w,h);
	}
	/*管理员-角色-编辑*/
	function admin_edit(title,url,id,w,h){
		layer_show(title,url+'?id='+id,w,h);
	}
	/*管理员-角色-删除*/
	function admin_del(obj,id){
		layer.confirm('管助者删除须谨慎，确认要删除吗？',function(index){
			$.ajax({
				type: 'DELETE',
				url: "{:url('AdminUser/delete')}",
				data:{id:id},
				dataType: 'json',
				success: function(data){
          if(data.state){
						$(obj).parents("tr").remove();
						layer.msg(data.msg,{icon:1,time:1000});
					}else {
            layer.msg(data.msg,{icon:5,time:1000});
					}
				},
				error:function(data) {
					//console.log(data.msg);
				},
			});
		});
	}

/*管理员-批量删除*/
function datadel(obj){
	var chk_value =[];
	$('input[name="id[]"]:checked').each(function(){
		chk_value.push($(this).val());
	});
	if (chk_value.length==0 ) {
		layer.msg('未选中任意项', {icon: 5,time:1000});
	}else {
		$.ajax({
			type: 'DELETE',
			url: "{:url('AdminUser/allDelete')}",
			data:{id:chk_value},
			dataType: 'json',
			success: function(data){
					if(data.state){
						layer.msg(data.msg,{icon:1,time:1000});
					}else {
						layer.msg(data.msg,{icon:5,time:1000});
					}
			}
		});
	}

}
</script>
</body>
</html>
